Repository navigation
fix: render LaTeX math in chat messages - #46
Closed
xiuguangli wants to merge 1 commit into
Closed
xiuguangli wants to merge 1 commit into
xiuguangli wants to merge 1 commit into
Conversation
- Render inline and display math with KaTeX - Accept display delimiters that share lines with the formula - Restore KaTeX layout after DOMPurify sanitization - Bundle KaTeX assets and allow them in the webview CSP
Owner
|
Thank you @xiuguangli for the contribution! I merged the feature along with fixing a few small bugs it contained; performance optimizations and streaming requirements. More details: #45 (comment) |
koltyakov
added a commit
that referenced
this pull request
Oct 22, 2026
Bundle KaTeX and local fonts for inline and display math, with horizontal scrolling for wide equations. Keep code and currency literal and render TeX with trust disabled. Show a fixed-size streaming indicator while formulas and other Markdown syntax are incomplete, preserving settled content as more text arrives. Reuse finalized Markdown across virtual remounts, batch scroll-mounted row measurements before saving anchors, and use exact content heights during text entrance animations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #45
Summary
Chat currently renders
$...$and$$...$$as raw text. This adds KaTeX rendering for inline and display math, including the display form models commonly emit where the delimiters share lines with the formula:Changes
marked-katex-extensionandkatex, and render math inMarkdownRenderer.$$...$$when the delimiters share lines with the formula. The extension only accepts delimiters on their own lines by default.styleattributes through the general Markdown sanitizer.font-srcfrom the webview resource source.Before / After
Before:
After:
Verification
npm run lintnpm run fmtnpm run typechecknpm run typecheck:suggestionsnpx vitest run src/webview/components/MarkdownRenderer.test.ts src/webview/components/MarkdownRenderer.perf.test.ts src/webview/components/MarkdownRenderer.lazy-highlight.test.tsx src/webview/perf/markdown-renderer.perf.test.ts src/extension/webview-html.test.ts(231 tests)npm test(10,460 passed, 51 skipped). The only failure issrc/extension/open-code-process.test.ts > rejects public and symlinked default ownership records without altering them, which also fails on unmodifiedmainin this environment.$...$/$$...$$not rendered) #45.Notes
$...$keeps the extension's boundary rules, so currency such as$5is not treated as math.katexis pinned to0.18.10becausemarked-katex-extensionsupports<0.19; mermaid keeps its existing0.19.0override, so npm nests that copy.